package com.platform.comm.config;

import lombok.Data;
import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.convert.DurationUnit;
import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.Map;

/**
 * Description: 缓存配置
 *
 * @author libin Created on 2019/7/18
 **/
@ConfigurationProperties(prefix = "cache.redis")
@Validated
public class CacheRedisProperties {

    @Getter
    private final Redis redis = new Redis();

    @Valid
    @Data
    public static class Redis {

        /**
         * 过期时间
         */
        @DurationUnit(ChronoUnit.SECONDS)
        private long timeoutSeconds = 60 * 10;

        /**
         * Mapping of cacheNames to expira-after-write timeout in seconds
         */
        private Map<String, Long> cacheExpirations = new HashMap<>();
    }

}
